--- %%NOBANNER%% -->
/*-------------------<-- Start of Description-->---------------------\
| Capitalize the initial character for each word in the string; |
|---------------------<-- End of Description-->----------------------|
|--------------------------------------------------------------------|
|------------<-- Start of Files or Arguments Needed-->---------------|
| A string or a quoted string will be needed; |
|---------------<-- End of Files Arguments Needed-->-----------------|
|------------------<-- Start of Files Created-->---------------------|
| Example: proc print data=attest.implant(obs=10); var pt impdt; |
| title %initcaps("attest implant"); run; |
| Usage: %initcaps(string); |
\-------------------<-- End of Files Created-->---------------------*/
%macro initcaps/parmbuff;
/*--------------------------------------------\
| Author: Duo Zhou; |
| Created: 9-23-2001 8:42pm; |
| Purpose: Capitalize the initial character of|
| each word in the string; |
\--------------------------------------------*/
%local titletxt1 titletxt2 title;
%global newtitle;
%if (%length(&syspbuff) gt 2) %then %do;
%let titletxt1=%substr(&syspbuff, 2, %eval(%length(&syspbuff)-2));
%let titletxt2=%sysfunc(dequote(&titletxt1));
%let newtitle=;
%let lastchar=;
%do _i_=1 %to %length(&titletxt2);
%let char=%qsubstr(&titletxt2,&_i_,1);
%if (&lastchar=%str( ) or &_i_=1) %then %do;
%let char=%qupcase(&char);
%end;
%else %do;
%let char=%qlowcase(&char);
%end;
%let newtitle=&newtitle&char;
%let lastchar=&char;
%end;
%if (%index(titletxt1,%str(%'))) or (%index(titletxt1,%str(%"))) %then %do;
%put;"&newtitle"
%end;
%else %do;
%put;&newtitle
%end;
%end;
%else %do;
%put ==> Alert! You forgot give me a string.;
%end;
%mend initcaps;